﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pixels.Logic
{
    public enum Technologies
    {
        none,
        electrified_fence,      // [ ] allows surplus power to be diverted to the fence, to increase defense value
        advanced_hydroponics,   // [ ] allows 4 people per farm (up from 2)
        advanced_engineering,   // [ ] allows 4 technicians per forge (up from 2)
        pulse_rifles,           // [ ] increases soldier firepower
        alien_corpse,           // [ ] increases soldier firepower, opens up advanced hydroponics
        frequency_analysis,     // [ ] needed for constructing distress beacon            
        crystal_refraction,     // [ ] solar array adjacent to crystals gain more power
        weather_patterns,       // [ ] if you have manned laboratories, you get a weather forecast for next turn
        alien_biology,          // [ ] you can spend Food and Tech to spray toxins into the atmosphere that kill enemy attacks


        ubound
    }

    public class Technology
    {
        
        public readonly Technologies ID;
        public readonly int cost;
        public readonly string name;
        public readonly string description;
        public bool researched { get; private set;}
        public bool allowed { get; private set; }

        public int researchInvested {get; private set;}

        public Technology(Technologies id, string name, string description = "[add description please : +2 thingamabob, +4 bloop]", int cost = 10) {
            this.ID = id;
            this.cost = cost;
            this.name = name;
            this.description = description;
            this.researched = false;
            this.researchInvested = 0;
            this.resourcesNeededToStartResearch = new ResourcePool();
        }

        public void advanceResearch(int howMuch) {
            this.researchInvested += howMuch;
            if (this.researchInvested > cost) this.researched = true;                            
        }

        public void allow() {
            this.allowed = true;
        }

        public ResourcePool resourcesNeededToStartResearch;

    }

    static public partial class Utilities {
        static public bool Researched(this Technologies tech) { 
            return GlobalConsts.getTechnology(tech).researched;
        }

        static public bool Allowed(this Technologies tech) {
            return GlobalConsts.getTechnology(tech).allowed;
        }
    }
}
